package com.dream.keigezhushou.Activity.kege.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.dream.keigezhushou.Activity.wigdt.VideoConstant;
import com.dream.keigezhushou.R;
import com.squareup.picasso.Picasso;

import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayerStandard;

/**
 * Created by Administrator on 2017/3/17.
 * <p/>
 * K歌我的关注
 */
public class KeMyAttentionAdapter extends BaseAdapter {
    private Context mContext;

    int c = 12;
    public ItemOnClickListening itemOnClickLinister = null;
    int postion;


    public void setItemOnClickListening(ItemOnClickListening listening) {
        this.itemOnClickLinister = listening;
    }

    public KeMyAttentionAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return c;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        postion = i;
        ProHolder mHolder = null;
        if (view == null) {
            view = LayoutInflater.from(mContext).inflate(R.layout.item_my_attention_list, null);
            mHolder = new ProHolder();
            mHolder.itemLinear = (LinearLayout) view.findViewById(R.id.item_my_attention_linear);
//            ivPost = (ImageView) itemView.findViewById(R.id.iv_video_post);
            mHolder.tvEvaluate = (TextView) view.findViewById(R.id.tv_evaluate);
            mHolder.tvShare = (TextView) view.findViewById(R.id.tv_share);
            view.setTag(mHolder);
        } else {
            mHolder = (ProHolder) view.getTag();
        }

        mHolder.tvEvaluate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (itemOnClickLinister != null) {

                    itemOnClickLinister.onEvaluateClick(postion);

                }

            }
        });


        mHolder.tvShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (itemOnClickLinister != null) {

                    itemOnClickLinister.onShareClick(postion);
                }

            }
        });


        mHolder.itemLinear.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (itemOnClickLinister != null) {

                    itemOnClickLinister.onItemClick(postion);
                }
            }
        });


        return view;
    }


    class ProHolder {
        LinearLayout itemLinear;
        TextView tvEvaluate;
        TextView tvShare;
    }


    public interface ItemOnClickListening {

        public void onItemClick(int position);

        public void onEvaluateClick(int position);

        public void onShareClick(int position);
    }


}